package com.example.mengchun;

import android.app.Activity;
import android.graphics.Color;
import android.os.Build;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.WindowManager;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

/**
 * Created by Administrator on 2017/10/12 0012.
 */

public class Mutil {
    public static void transparentStatusBar(Activity activity) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
            activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
            activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
            activity.getWindow().setStatusBarColor(Color.TRANSPARENT);
        } else {
            activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        }
    }
    public static void gethttpconnec(final String path, final Handler handler){
        new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    Log.d("dsa",path);
                    String json;
                    URL url=new URL(path);
                    HttpURLConnection conn= (HttpURLConnection) url.openConnection();
                    conn.setRequestMethod("GET");
                    InputStream in=conn.getInputStream();
                    BufferedReader bufferedReader=new BufferedReader(new InputStreamReader(in));
                    json=bufferedReader.readLine();
                    Message message=handler.obtainMessage();
                    message.obj=json;
                    handler.sendMessage(message);
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }).start();

    }
    public static String xingzuo(String mo,String day){
        int a = Integer.parseInt(mo);
        int b = Integer.parseInt(day);
        String aa = "";
        switch (a){
            case 1:
                if (b<=20){
                    aa = "摩羯座";
                }else{
                    aa = "水瓶座";
                }
                break;
            case 2:
                if (b<=19){
                    aa = "水瓶座";
                }else{
                    aa = "双鱼座";
                }
                break;
            case 3:
                if (b<=20){
                    aa = "双鱼座";
                }else{
                    aa = "白羊座";
                }
                break;
            case 4:
                if (b<=20){
                    aa = "白羊座";
                }else{
                    aa = "金牛座";
                }
                break;
            case 5:
                if (b<=21){
                    aa = "金牛座";
                }else{
                    aa = "双子座";
                }
                break;
            case 6:
                if (b<=21){
                    aa = "双子座";
                }else{
                    aa = "巨蟹座";
                }
                break;
            case 7:
                if (b<=22){
                    aa = "巨蟹座";
                }else{
                    aa = "狮子座";
                }
                break;
            case 8:
                if (b<=23){
                    aa = "狮子座";
                }else{
                    aa = "处女座";
                }
                break;
            case 9:
                if (b<=23){
                    aa = "处女座";
                }else{
                    aa = "天枰座";
                }
                break;
            case 10:
                if (b<=23){
                    aa = "天枰座";
                }else{
                    aa = "天蝎座";
                }
                break;
            case 11:
                if (b<=22){
                    aa = "天蝎座";
                }else{
                    aa = "射手座";
                }
                break;
            case 12:
                if (b<=21){
                    aa = "射手座";
                }else{
                    aa = "摩羯座";
                }
                break;
        }
        return aa;
    }
}
